package com.hjx.util;

import com.hjx.entity.SysMenu;
import com.hjx.mapper.SysMenuMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2020/6/18 - 9:32
 */
@Component
public class MenusUtil {
    @Resource
    SysMenuMapper sysMenuMapper;
    public void getMenuAndChildren(SysMenu menu){
        if (menu.getIsLeaf()==1){
            return;
        }
        List<SysMenu> menus = sysMenuMapper.findByParentId(menu.getMid());
        menu.setChildren(menus);
        for (SysMenu m : menus) {
            getMenuAndChildren(m);
        }

    }
}
